package com.ljx.offer;

import org.junit.Test;

import java.util.ArrayList;
import java.util.HashMap;

/**
 * @author 李捷禧
 * Date: 2023/3/30
 * ClassName: c
 */

public class C_56_2 {
    /**
     * 自己思路，暴力解法
     * 运行时间/内存 占用比较大
     * @param nums
     * @return
     */
    public int singleNumber(int[] nums) {
        HashMap<Integer, Boolean> hashMap = new HashMap<>();
        for (int num : nums) {
            hashMap.put(num,!hashMap.containsKey(num));
        }
        for (int num : nums) {
            if(hashMap.get(num)) return num;
        }
        return 0;
    }


    @Test
    public void test(){
       int[] nums = new int[]{3,4,3,3};
        System.out.println(singleNumber(nums));

    }
}
